<?php

include_once '../../library/config.php';
include_once '../../model/userlist.php';

$list = new UserList();
$entity = new UserList();
$entity->request();

try {

//    验证验证码

    if (!preg_match("/(?!^\d+$)(?!^[a-zA-Z]+$)[0-9a-zA-Z]{6,16}/", $entity['pwd'])) {
        throw new Exception("102"); //匹配密码格式
    }

    $list->keyvalue("account", $entity['account'])->keyvalue("pwd", md5($entity['account'].$entity['pwd']));
    if (!$list->update()->where("account=".$entity['account'])->submit()) {
        throw new Exception("115"); //修改失败
    }
} catch (Exception $ex) {
    $list->rsscode($ex);
}

echo $entity->toJson();
